﻿using System;
using System.Reflection;
using SType = System.Type;

namespace UFrame
{

    /// <summary>
    /// MonoBehaviour子类 一个抽象单列类
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public abstract class SingletonMono<T> : BaseMono where T : class
    {
        private static T instance = null;

        public static T I
        {
            get
            {
                return instance;
            }
            set
            {
                instance = value;
            }
        }

        protected  void Awake()
        {
            //base.Awake();
            if (instance != null)
            {
                PLDebug.LogError(typeof(T).Name + " 出现多个单例");
            }
            instance = this as T;

        }

        protected override void OnDestroy()
        {
            base.OnDestroy();
            instance = null;
        }

    }
}

